<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      img {
        width: 100px;
      }
    </style>
  </head>
  <body>
    <ul>
      <!-- <li>
        <img src="" alt="" />
        <p></p>
      </li> -->
    </ul>
    <script type="module">
      import http from "./js/request.js";

      async function loadList() {
        //http也可以当函数用
        let r = await http({
          url: "/goods/list",
          method: "get",
          params: {
            current: 1,
            pagesize: 15,
          },
        });
        //请求成功以后
        console.log(r.data);
        //解构赋值
        let { list } = r.data;
        let html = "";
        list.forEach((v) => {
          html += `
            <li>
              <a href="04-item.html?id=${v.goods_id}"><img src="${v.img_big_logo}" alt="" />
              <p>${v.title}</p></a>
            </li>
          `;
        });
        document.querySelector("ul").innerHTML = html;
      }

      loadList();
    </script>
  </body>
</html>
